package com.dsa.team5.kanban.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.dsa.team5.kanban.dao.StatusDao;
import com.dsa.team5.kanban.model.Status;
import com.dsa.team5.kanban.utils.CustomHibernateDaoSupport;

@Repository("statusDao")
public class StatusDaoImpl extends CustomHibernateDaoSupport implements
		StatusDao {

	@Autowired
	SessionFactory sessionFactory;

	@Override
	public void save(Status status) {
		getHibernateTemplate().save(status);
	}

	@Override
	public void update(Status status) {
		getHibernateTemplate().update(status);
	}

	@Override
	public void delete(Status status) {
		getHibernateTemplate().delete(status);
	}
	
	@Override
	public Status getStatus(Long id) {
	    return getHibernateTemplate().get(Status.class, id);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Status> getStatusByKanbanId(Long kanbanId) {
		return getHibernateTemplate().find(
				"from Status where kanbanId = " + kanbanId
						+ " order by statusId asc");
	}
}
